﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Models;
using BLL;

namespace CSMF
{
    public partial class Charts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindLatest();
                BindHighest();
                BindMost();
            }
        }

        protected string GetPoint(int id)
        {
            string point = "";
            Models.VideoInfo info = VideoInfoManager.GetVideoInfoByID(id);
            if (info.Point == 0)
            {
                point = Convert.ToSingle((VideoPointManager.GetVideoPointsSumByVideoID(id) / VideoPointManager.GetVideoPointsCountByVideoID(id))).ToString();
                if (point.Equals("非数字"))
                {
                    point = "0";
                }
            }
            else
            {
                point = info.Point.ToString();
            }
            return point;
        }

        protected void BindLatest()
        {
            IList<Models.VideoInfo> pic = VideoInfoManager.GetVideoInfosTop10Latest();
            rptLatest.DataSource = pic;
            rptLatest.DataBind();
        }

        protected void BindHighest()
        {
            //IList<VideoInfo> pic = VideoInfoManager.GetVideoInfosTop10ByPoint();
            //rptHighest.DataSource = pic;
            //rptHighest.DataBind();
            IList<View_Point> pic = View_PointManager.GetAllView_Points();
            rptHighest.DataSource = pic;
            rptHighest.DataBind();
        }

        protected void BindMost()
        {
            IList<Models.VideoInfo> pic = VideoInfoManager.GetVideoInfosTop10ByCount();
            rptMost.DataSource = pic;
            rptMost.DataBind();
        }
    }
}
